package com.xtedu.examproject.service;

import com.xtedu.examproject.dao.base.MenuDao;
import com.xtedu.examproject.dao.impl.MenuDaoImpl;
import com.xtedu.examproject.entity.Menu;

import java.sql.SQLException;
import java.util.List;

public class MenuService {
    private MenuDao menuDao;

    public MenuService(){
        menuDao = new MenuDaoImpl();
    }

    public List<Menu> findMenusByRoleId(int roleId) throws Exception{
        return menuDao.findMenusByRoleId(roleId);
    }
    public int insert(Menu menu) throws Exception{
        return menuDao.insert(menu);
    }
    public int findIdByNameAndPath(String name, String path) throws SQLException {
        return menuDao.findIdByNameAndPath(name,path);
    }

    public List<Menu> findAll() throws Exception {
        return menuDao.findAll();
    }

    public Menu findById(int id) throws Exception {
        return menuDao.findById(id);
    }
    public int update(Menu menu) throws Exception{
        return menuDao.update(menu);
    }

    public int delete(Menu menu) throws Exception {
        return menuDao.delete(menu);
    }
}
